package com.dog.basics.admin.controller.mtkj;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.mtkj.DepositFromDto;
import com.dog.basics.bean.vo.admin.mtkj.DepositVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.util.IPageVo;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.mtkj.IMtDeviceDepositService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 设备押金记录 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-09-29
 */
@RestController
@RequestMapping("/pc/device/deposit")
@Api(value = "设备押金记录模块", tags = "设备押金记录模块")
@AllArgsConstructor
public class MtDeviceDepositController {
    private final IMtDeviceDepositService mtDeviceDepositService;

    /**
     * @Description: 设备押金记录列表
     * @Param: DepositFromDto
     * @return: IPage<DepositVo>
     * @Author: wph
     * @Date:
     */

    @ApiOperation(value = "设备押金记录列表", notes = "pc:mtDeviceDeposit:page")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceDeposit:page')")
    public R<IPageVo<DepositVo>> page(PageParam page, DepositFromDto obj) {
        IPageVo<DepositVo> list = mtDeviceDepositService.getPageList(page, obj);
        return R.ok(list);
    }


    /**
     * @Description: 删除设备押金记录
     * @Param: ids
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("删除设备押金记录")
    @ApiOperation(value = "删除设备押金记录", notes = "pc:mtDeviceDeposit:delete")
    @ApiImplicitParam(value = "设备押金记录Id", name = "id", dataType = "Long", required = true)
    @DeleteMapping("/delete/{id}")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceDeposit:delete')")
    public R<Boolean> delete(@PathVariable("id") Long id) {
        return R.ok(mtDeviceDepositService.deleteObj(id));
    }


    /**
     * @Description: 确认退款
     * @Param: ids
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @ApiOperation(value = "确认退款", notes = "pc:mtDeviceDeposit:return")
    @ApiImplicitParam(value = "设备押金Id", name = "id", dataType = "Long", required = true)
    @PutMapping("/returnObj/{id}")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceDeposit:return')")
    public R editOrderInfoFund(@PathVariable("id") Long id) {
        return R.ok(mtDeviceDepositService.pcReturnObj(id));
    }
}
